package com.advertise.service;

import java.util.ArrayList;
import java.util.List;


import com.advertise.dao.MenuDAO_IFace;
import com.advertise.model.Menu;
import com.advertise.model.TreeNode;
import com.advertise.service.BaseService_Impl;
import com.advertise.service.MenuService_IFace;


public class MenuService_Impl extends BaseService_Impl<Menu, Integer> implements
		MenuService_IFace {
	private MenuDAO_IFace menuDAO;
	
	public MenuDAO_IFace getMenuDAO() {
		return menuDAO;
	}
	public void setMenuDAO(MenuDAO_IFace menuDAO) {
		this.menuDAO = menuDAO;
	}
	public List<TreeNode> getSubMenus(int menuId){
		
		return menuDAO.getSubMenus(menuId);
	}
	
	
	public List<TreeNode> getSubMenusFromMenuList(int menuId,List<TreeNode> allMenus){
		List<TreeNode> subMenus = new ArrayList<TreeNode>();
		System.out.println("all menu is :"+allMenus.size());
		for(int i = 0; i<allMenus.size(); i++){
			TreeNode treeNode = allMenus.get(i);
			if(treeNode.getParent() == menuId){
				
				subMenus.add(treeNode);
			}
		}
		return subMenus;
	}
	
}
